<?php

	class Shop extends AppModel {
		var $name = 'Shop';
		var $useTable = 'shops';
		
		var $hasMany = array(
			'Configuration',
			'Product',
			'Taxonomy',
			'Post',
			'IndustryShop',
			'Menu'
		);

		var $belongsTo = array(
			'Country',
			'Currency',
			'User'
		);

		var $hasAndBelongsToMany = array(
			'Industry' => array(
				'className' => 'Industry',
				'joinTable' => 'industries_shops',
				'foreignKey' => 'shop_id',
				'associationForeignKey' => 'industry_id'
			)
		);
	
		var $virtualFields = array();
		
		function __construct($id = false, $table = null, $ds = null) {
			parent::__construct($id, $table, $ds);
			$this->virtualFields['logo_url'] = String::insert('CONCAT(\'' . Router::url('/media/shop/', true) . '\', :alias.id, \'/\', :alias.logo)', array('alias' => $this->alias));
		}
	}
